#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    ui->stackedWidget->setCurrentIndex(0);

    mModel = new FormulaListModel;
    mModel->loadForms();
    ui->listView->setModel(mModel);

    connect(ui->listView,SIGNAL(clicked(QModelIndex)),this,SLOT(showWidgetForm(QModelIndex)));

    mLeftSoftKey = new QAction("retour", this);
    mLeftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
    connect(mLeftSoftKey,SIGNAL(triggered()),this,SLOT(showMenuList()));
addAction(mLeftSoftKey);
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::showMenuList()
{
    ui->stackedWidget->setCurrentIndex(0);

}
void MainWindow::showWidgetForm(QModelIndex index)
{
    ui->scrollArea->takeWidget();

    ui->scrollArea->setWidget(mModel->formWidget(index));

    ui->stackedWidget->setCurrentIndex(1);





}
